local yicai = fk.CreateSkill{
    name = "lingling__yicai",
    tags = {Skill.Compulsory},
}
Fk:loadTranslationTable{
    ["lingling__yicai"] = "溢才",
    [":lingling__yicai"] = "锁定技，出牌阶段结束时，若你有手牌，你随机获得三张不同花色的牌。",
    --["#lingling__yicai"] = "是否发动 溢才，以弃置所有手牌，然后随机获得三张不同花色的牌",
}

yicai:addEffect(fk.EventPhaseEnd,{
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(yicai.name) and player.phase == Player.Play and #player:getCardIds("h") > 0
    end,
    --[[on_cost = function (self, event, target, player, data)
        if player.room:askToSkillInvoke(player,{
            skill_name = yicai.name,
            prompt = "#lingling__yicai",
        }) then
            return true
        end
    end,]]--
    on_use = function (self, event, target, player, data)
        local room = player.room

        --[[local cards = table.filter(player:getCardIds("h"),function (cardID)
            return not player:prohibitDiscard(cardID)
        end)
        if #cards > 0 then
            room:throwCard(cards, yicai.name, player)
        end]]--

        local suits = table.random({"spade", "heart", "club", "diamond"},3)
        local gains = {}
        for index, suit in ipairs(suits) do
            local card = room:getCardsFromPileByRule(".|.|"..suit, 1, "allPiles")
            if #card > 0 then
                table.insertIfNeed(gains, card[1])
            end
        end
        if #gains > 0 then
            room:obtainCard(player, gains, false, fk.ReasonJustMove, player, yicai.name)
        end
    end,
})

return yicai